/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package generadorva;

import ec.util.MersenneTwisterFast;

/**
 *
 * @author USUARIO
 */
public class Costo {
    
    private BoxMuller demanda;
    private double costoUnidad;
    private double costoFaltante;
    private double costoSobrante;

    public Costo(BoxMuller demanda, double costoUnidad, double costoFaltante, double costoSobrante) {
        this.demanda = demanda;
        this.costoUnidad = costoUnidad;
        this.costoFaltante = costoFaltante;
        this.costoSobrante = costoSobrante;
    }
    
    public double calcularCosto(int inventario, MersenneTwisterFast prng){
        double D = Math.round(demanda.generate(prng));
        if (inventario >= D) {
            return costoUnidad*inventario + (inventario - D)*costoSobrante;
        } else {
            return costoUnidad*inventario + (D - inventario)*costoFaltante;
        }
    }
    
}
